package com.shopcz.mx.shopcar.manager;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;
import com.shopcz.dao.TypeDao;
import com.shopcz.pojo.Type;

public class GetTypeForFaBu extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		this.doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");	
		Gson gson=new Gson();
		List<Type> types=new ArrayList<Type>();
		TypeDao tDao=new TypeDao();
		types=tDao.QueryType();
		resp.setContentType("text/application;charset=utf-8");
		String jsonList=gson.toJson(types);
		PrintWriter pw=resp.getWriter();
		pw.write(jsonList);
		pw.flush();
	}
	
}
